<!--办理-->
<template>
	<view class="mainPge">
		<!-- 公共头部 -->
		<headerPublic title="全委通知" @backfn="backfn" />
		<!--主体-->
		<view class="page-content"
			:class="{ outbottom: (tabtype == 'iapprove' && actiontype !== 'seeinfo') || (initbusinessStatus == 'AUDITED' && tabtype == 'icreat') }">
			<!-- 顶部固定 -->
			<view class="tabs tabs-fixd">
				<view class="tbrow">
					<view class="tabit" :class="{ tabchecked: tabcheck == it.value }" v-for="(it, index) in tabs"
						:key="index" @click="checkTab(it.value)">
						<text class="t1">{{ it.lable }}</text>
					</view>
				</view>
			</view>
			<!-- 基本信息-->
			<view v-if="tabcheck == 1" class="mainct">
				<view class="frct">
					<view class="fr-colum">
						<view class="fr-lable fr-2">标题</view>
						<uv-input v-if="initbusinessStatus == 'AUDITED' && tabtype == 'icreat'" v-model="pageInfo.title"
							border="none" class="ct ctinfo_edit" style="margin-bottom: 26rpx"></uv-input>
						<view class="ct" style="margin-bottom: 26rpx" v-else>{{ pageInfo.title }}</view>
					</view>
					<view class="fr-colum">
						<view class="fr-lable fr-2">正文</view>
						<uv-textarea :maxlength="-1" autoHeight v-model="pageInfo.content" class="ct ctinfo_edit"
							v-if="initbusinessStatus == 'AUDITED' && tabtype == 'icreat'"></uv-textarea>
						<view class="ct borderno" v-else v-html='pageInfo.content'></view>
					</view>
				</view>
				<view class="frct" v-if="tabtype == 'iapprove' && actiontype !== 'seeinfo'">
					<view class="fr-colum">
						<view class="fr-lable fr-2">审批意见：</view>
						<!-- 编辑的时候-->
						<uv-textarea :maxlength="-1" autoHeight v-model="pageInfo.auditMemo" placeholder="请输入审批意见"
							style="margin-bottom: 10px"></uv-textarea>
					</view>
				</view>
				<view
					v-if="(auditItems.length > 0 && tabtype !== 'iapprove' && tabtype !== 'notice') || (auditItems.length > 0 && tabtype == 'iapprove' && actiontype == 'seeinfo')">
					<view class="frct" v-for="(it, index) in auditItems" :key="index">
						<view class="fr-colum">
							<view class="fr-lable fr-2">审批意见：</view>
							<!-- 查看详情的时候-->
							<view>
								<view class="ct borderno">{{ it.memo }}</view>
								<view class="fr-row frit">
									<view class="fr-lable fr-2"></view>
									<view class="defaultstr" style="font-size: 26rpx">{{ it.operatorName }} {{
										it.completeTime }}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="frct" v-if="initbusinessStatus == 'AUDITED' && tabtype == 'icreat'">
					<view class="fr-colum">
						<view class="fr-lable">
							<text class="redico">*</text>
							选择路径：
						</view>
						<uv-radio-group v-model="pageInfo.businessStatusName" class="bline">
							<uv-radio size="15" activeColor="#2d75d7" :customStyle="{ margin: '8px' }"
								v-for="(item, index) in radiolist3" :key="index" :label="item.name" :name="item.name"
								@change="businessStatuschange"></uv-radio>
						</uv-radio-group>
						<view class="choseP" v-if="pageInfo.businessStatus == 'UNDO'">
							<view class="itp" v-for="(item, index) in auditarry" :key="index">
								<image src="/static/docmumentImg/ico-defalutp.png" class="icopimg"></image>
								<text class="t1">{{ item }}</text>
								<image src="/static/docmumentImg/icdelt.png" class="icdelt"
									@click="deletPerson(index, item)"></image>
							</view>
							<view class="itp" @click="checkpersonTitel = '添加审批人';getPerson('选择审核人');">
								<image src="/static/docmumentImg/ico-addp.png" class="icopimg"></image>
								<text class="t2">添加审批人</text>
							</view>
						</view>
					</view>
				</view>
				<!-- 填写回执 未回执-->
				<view class="frct"
					v-if="(tabtype !== 'icreat' && tabtype !== 'iapprove' && tabtype !== 'notice') || (tabtype == 'notice' && pageInfo.receiptStatus == 'UNDO')">
					<view class="fr-colum">
						<view class="fr-lable">
							<text class="redico">*</text>
							填写回执：
						</view>
						<uv-textarea :maxlength="-1" autoHeight v-model="pageInfo.receiptMemo" placeholder="请按通知需求填写回执"
							style="margin-bottom: 10px"></uv-textarea>
						<view class="btflex">
							<view class="sfrumit" @click="hzsumit()">提交</view>
						</view>
					</view>
				</view>
				<!-- 填写回执 已经回执过的-->
				<view class="frct"
					v-if="(tabtype !== 'icreat' && tabtype !== 'iapprove' && tabtype !== 'notice') || (tabtype == 'notice' && pageInfo.receiptStatus == 'DONE')">
					<view class="fr-colum">
						<view class="fr-lable">
							<text class="redico">*</text>
							填写回执：
						</view>
						<view class="ct borderno">{{ pageInfo.receiptMemo }}</view>
					</view>
				</view>
				<!-- 图片展示-->
				<view class="frct"
					v-if="(tabtype !== 'icreat' && tabtype !== 'iapprove' && showimglist.length > 0) || (tabtype == 'notice' && showimglist.length > 0)">
					<view class="fr-colum">
						<image :src="it.previewURL" class="fr-img" v-for="(it, index) in showimglist"
							:key="it.previewURL"></image>
					</view>
				</view>
				<!-- 附件展示-->
				<view class="frct"
					v-if="(tabtype !== 'icreat' && tabtype !== 'iapprove' && tabtype !== 'notice') || (infofilelist.length > 0 && tabtype == 'notice')">
					<view class="fr-colum">
						<view class="fr-itfile" v-for="(it, index) in infofilelist" :key="index">
							<view class="fr-row" @click="showPreview(it.extName, index, it.previewURL)">
								<!-- 根据it.extName 显示下面对应个图片和图标 如果是pdf就显示pdf的-->
								<image src="/static/docmumentImg/ico-pdf.png" class="fileico-img"
									v-if="isFileOfType(it.extName, 'pdf')"></image>
								<image src="/static/docmumentImg/ico-world.png" class="fileico-img"
									v-else-if="isFileOfType(it.extName, 'document')"></image>
								<image src="/static/docmumentImg/ic-img.png" class="ic-imgxz"
									v-else-if="isFileOfType(it.extName, 'image')"></image>
								<uv-icon name="folder" class="fileico-down" size="25" color="#2D75D7" v-else></uv-icon>
								<text class="file-name">{{ it.fileName }}</text>
								<text class="file-size">{{ it.fileSize }}</text>
							</view>
							<image src="/static/docmumentImg/ic-dowload.png" class="ic-dowload"
								@click="downloadFileFn(it.previewURL, it.fileName)"></image>
						</view>
					</view>
				</view>
				<view class="frct">
					<view class="fr-row frit">
						<view class="fr-lable fr-2">创建部门：</view>
						<view class="defaultstr" v-if="tabtype == 'iapprove' || tabtype == 'notice'">
							{{ pageInfo.agentOrgName }}
						</view>
						<view class="defaultstr" v-else>{{ pageInfo.deptName }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">创建时间：</view>
						<view class="defaultstr">{{ pageInfo.createTime }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">创建人：</view>
						<view class="defaultstr">{{ pageInfo.agentName }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">联系电话：</view>
						<view class="defaultstr"
							@click="makePhone(tabtype == 'iapprove' || tabtype == 'notice' ? pageInfo.auditInfo.telephone : pageInfo.telephone)">
							<view class="fr-row rowflexend">
								<image src="/static/docmumentImg/ic_phone.png" class="ic_phone"></image>
								<text v-if="tabtype == 'iapprove' || tabtype == 'notice'">{{
									pageInfo.auditInfo.telephone }}</text>
								<text v-else>{{ pageInfo.telephone }}</text>
							</view>
						</view>
					</view>
					<view class="fr-row frit" @click="opendataChoes">
						<view class="fr-lable fr-2">公告日期：</view>
						<view class="defaultstr" v-if="pageInfo.publishTime || pageInfo.auditInfo.publishTime">
							{{ tabtype == 'iapprove' || tabtype == 'notice'?pageInfo.auditInfo.publishTime : pageInfo.publishTime }}
						</view>
						<view class="qxzstr" v-else>请选择日期</view>
						<image v-if="initbusinessStatus == 'AUDITED' && tabtype == 'icreat'"
							src="/static/docmumentImg/ico-date.png" class="ico-date"></image>
					</view>
					<!-- 发布范围可编辑-->
					<view v-if="initbusinessStatus == 'AUDITED' && tabtype == 'icreat'">
						<view class="fr-row frit">
							<view class="fr-lable fr-2">
								发布范围
								<text class="redico">*</text>
							</view>
							<uv-radio-group v-model="pageInfo.publishScopeName">
								<uv-radio size="15" activeColor="#2d75d7" :customStyle="{ margin: '8px' }"
									v-for="(item, index) in radiolist" :key="index" :label="item.name" :name="item.name"
									@change="publishScopechange"></uv-radio>
							</uv-radio-group>
						</view>
						<view class="fr-row frit" style="align-items: flex-start"
							v-if="pageInfo.publishScopeName == '指定传阅人'" @click="
								checkpersonTitel = '指定传阅人';
								getPerson('指定传阅人');
							">
							<view class="fr-lable fr-2">
								指定传阅人
								<text class="redico">*</text>
							</view>
							<view class="fr-colum frpp" style="max-width: 70%">
								<view class="go">
									<uv-icon name="arrow-right" color="#555" size="14"></uv-icon>
								</view>
								<text class="person">{{ pageInfo.readerNames }}</text>
							</view>
						</view>
					</view>
					<!-- 发布范围显示-->
					<view class="fr-row frit fritlast" style="align-items: baseline" v-else>
						<view class="fr-lable fr-2">发布范围：</view>
						<view style="width: 75%">
							<view class="defaultstr">
								{{ tabtype == 'iapprove' || tabtype == 'notice' ? pageInfo.auditInfo.publishScopeName :
									pageInfo.publishScopeName }}
							</view>
							<view style="padding-top: 5px; text-align: right"
								v-if="pageInfo.publishScope == 'DESIGNEE' || ((tabtype == 'iapprove' || tabtype == 'notice') && pageInfo.auditInfo.publishScope == 'DESIGNEE')">
								{{
									(tabtype == 'iapprove' || tabtype == 'notice') && pageInfo.auditInfo.publishScope ==
										'DESIGNEE'
										? pageInfo.auditInfo.readerNames
										: pageInfo.readerNames
								}}
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 办理记录-->
			<view v-if="tabcheck == 2" class="mainct">
				<view class="frct" v-for="(item, index) in recordlist" :key="index">
					<view class="fr-row frit">
						<view class="fr-lable fr-2">处理环节</view>
						<view class="defaultstr">{{ item.name }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">处理人</view>
						<view class="defaultstr">{{ item.operatorName }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">开始时间</view>
						<view class="defaultstr">{{ item.createTime }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">完成时间</view>
						<view class="defaultstr redstr" v-if="item.completeTime == '未完成'">未完成</view>
						<view class="defaultstr" v-else>{{ item.completeTime }}</view>
					</view>
					<view class="fr-row frit">
						<view class="fr-lable fr-2">处理状态</view>
						<view class="defaultstr">{{ item.operateStatusName}}</view>
					</view>
					<view class="fr-row frit fritlast" v-if="item.itemType=='AUDIT_DONE'">
						<view class="fr-colum">
							<view class="fr-lable fr-2">审批意见：</view>
							<view class="defaultstr" style="padding-top: 10px; text-align: left">{{ item.memo }}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 附件信息-->
			<view v-if="tabcheck == 3" class="mainct">
				<!-- 附件展示 替换图标-->
				<view class="frct" v-if="filelist.length > 0">
					<view class="fr-colum">
						<view class="fr-itfile" v-for="(it, index) in filelist" :key="index">
							<view class="fr-row" style="width: 91%"
								@click="showPreview(it.extName, index, it.previewURL)">
								<!-- 根据it.extName 显示下面对应个图片和图标 如果是pdf就显示pdf的-->
								<image src="/static/docmumentImg/ico-pdf.png" class="fileico-img"
									v-if="isFileOfType(it.extName, 'pdf')"></image>
								<image src="/static/docmumentImg/ico-world.png" class="fileico-img"
									v-else-if="isFileOfType(it.extName, 'document')"></image>
								<image src="/static/docmumentImg/ic-img.png" class="ic-imgxz"
									v-else-if="isFileOfType(it.extName, 'image')"></image>
								<uv-icon name="folder" class="fileico-down" size="25" color="#2D75D7" v-else></uv-icon>
								<text class="file-name">{{ it.fileName }}</text>
								<text class="file-size">{{ it.fileSize }}</text>
							</view>
							<image src="/static/docmumentImg/ic-dowload.png" class="ic-dowload"
								@click="downloadFileFn(it.previewURL, it.fileName)"></image>
						</view>
					</view>
				</view>
				<view class="nomoretxt" v-else>暂无数据</view>
			</view>
			<!--阅读情况-->
			<view v-if="tabcheck == 4" class="mainct">
				<view class="frct">
					<view class="fr-row frit" v-for="(item, index) in noticeInfos" :key="index">
						<view class="fr-lable fr-2">{{ item.readerName }}</view>
						<view class="defaultstr" :class="{ 'tag-red': item.readStatus == 'UNREAD', 'tag-yellow': item.readStatus == 'READED' }">
							<view v-if="item.receiptStatus =='DONE'" class="tag-yellow">{{ item.receiptMemo }}</view>
							<view v-else>{{ item.readStatusName }}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--底部固定 -->
		<view class="bt-foot"
			v-if="(tabtype == 'iapprove' && actiontype !== 'seeinfo') || (initbusinessStatus == 'AUDITED' && tabtype == 'icreat')">
			<view class="bt bt1" @click="handelSave()" v-if="!(initbusinessStatus == 'AUDITED' && tabtype == 'icreat')">
				保存</view>
			<view class="bt bt2" @click="handelSumit()">提交</view>
		</view>
		<!-- 提示消息框-->
		<uv-modal ref="modal" title="提示" content="您是否确认提交?" @confirm="confirm" :showCancelButton="true"
			cancelColor="#2D75D7" align="center"></uv-modal>
		<!-- 日历-->
		<uv-calendar ref="calendar" color="#2d75d7" iconColor="red" @confirm="dateconfirm"></uv-calendar>
	</view>
</template>
<script>
	import {
		getauditInfo,
		iapproveSave,
		iapproveSubmit,
		gettaskInfo,
		gethandlingRecord,
		getNoticeInfo,
		setReadStatus,
		getfilelist,
		getSaveDrafat,
		handelauditSubmit
	} from '@/api/commonNoticeApi.js';
	import {
		previewImgs,
		filterImageData,
		isImageExtension,
		previewPDF,
		downloadFile,
		isFileOfType
	} from '@/utils/public.js';
	import {
		makePhone
	} from "@/utils/common.js"
	export default {
		name: 'header',
		data() {
			return {
				checkpersonTitel: '',
				initbusinessStatus: '', // 查询初始化的businessStatus状态值，控制控件显示隐藏
				itId: '', //基本信息id
				businessId: '', // 页面传过来的id只有查看 业务id
				tabtype: '', // 判断是全委通知那个tab底下的业务处理icreat 是我创建的
				businessType: 'ALL', //业务类型 all 是全委通知  这块可以默认为all了
				actiontype: '', // 我审批的看详情过来
				pageInfo: {
					businessId: '', //业务id
					businessType: '', //业务类型
					// 基本信息数据
					title: '',
					content: '',
					agentName: '',
					deptName: '',
					telephone: '',
					publishTime: '',
					publishScope: '', // 发布范围DESIGNEE指定传阅人 all 全部人员
					publishScopeName: '', //发布范围文本
					readerNames: '', // 指定传阅人姓名（自定义展示数据）
					readerIds: '', // 指定传阅人id，逗号分开
					readerAccounts: '', // 指定传阅人的手机号（账号）
					busiAttachIds: '', // 附件ids
					busiAttachs: [], // 上传的附件文件
					auditItems: [], // 审批意见
					receiptStatus: '', //是否需要回执0：不需要1：需要
					receiptMemo: '', // 回执内容
					businessStatus: '', //选择路径
					businessStatusName: '', //选择路径名称
					auditorIds: '', // 添加审批人ids
					auditorNames: '', // 审批人名称
					auditorAccounts: '', // 添加审批人的手机号（账号）
					auditInfo: {
						//新套的内容主要用来去基本信息的公告日期，联系电话，和发布内容等
						publishScope: '',
						publishScopeName: '',
						publishTime: '',
						telephone: '',
						readerNames: '',
						readerIds: '',
						readerAccounts: '', // 指定传阅人的手机号（账号）
						busiAttachs: [] // 附件列表
					},
					auditMemo: '', // 审核意见
					deptName: '', // 创建部门
					agentOrgName: '', // 审批的列表、审批的详情、通知的列表、通知的详情 的部门我们都取值 
					createTime: '', // 创建时间
					agentName: '', // 创建人
					telephone: '', //联系电话
					publishTime: '' //公告日期
				},
				showimglist: [], // 主要用来显示图片
				auditItems: [], //查看详情时的审批意见数组
				recordlist: [], // 办理记录的数据
				radiovalue: '',
				noticeInfos: [], // 阅读情况
				infofilelist: [], //附件列表基本信息展示的附件列表
				filelist: [], //附件列表
				searchkey: '',
				tabcheck: 1,
				radiolist: [{
						name: '全部人员',
						disabled: false
					},
					{
						name: '指定传阅人',
						disabled: false
					}
				],
				radiolist3: [{
						name: '送审',
						disabled: false
					},
					{
						name: '发布信息',
						disabled: false
					}
				],
				tabs: [{
						lable: '基本信息',
						value: 1
					},
					{
						lable: '办理记录',
						value: 2
					},
					{
						lable: '附件信息',
						value: 3
					}
				],
				radiolist3: [{
						name: '送审',
						disabled: false
					},
					{
						name: '发布信息',
						disabled: false
					}
				],
				auditarry: [] // 页面用来显示的审批人数组
			};
		},
		onLoad(res) {
			this.itId = res.id ? res.id : '';
			this.businessId = res.businessId ? res.businessId : '';
			this.businessType = res.businessType ? res.businessType : 'ALL';
			this.tabtype = res.tabtype ? res.tabtype : '';
			this.actiontype = res.actiontype ? res.actiontype : '';
			this.getpageInfo();
		},
		onShow() {
			this.circulateSumint();
		},
		onPullDownRefresh() {
			this.getpageInfo();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			makePhone,
			isFileOfType,
			// 打开日期选择框
			opendataChoes() {
				if (this.initbusinessStatus == 'AUDITED' && this.tabtype == 'icreat') {
					this.$refs.calendar.open()
				}
			},
			//发布范围选择
			publishScopechange(val) {
				this.pageInfo.publishScopeName = val;
				this.pageInfo.publishScope = val == '全部人员' ? 'ALL' : 'DESIGNEE';
				this.pageInfo.readerIds = '';
				this.pageInfo.readerNames = '';
			},
			//日期选择
			dateconfirm(e) {
				this.pageInfo.publishTime = e[0];
			},
			// 删除审核人
			deletPerson(index) {
			  const fields = ['auditorIds', 'auditorNames', 'auditorAccounts'];
			  fields.forEach(key => {
			    this.pageInfo[key] = (this.pageInfo[key] || '').split(',').filter((_, i) => i !== index).join(',');
			  });
			  this.auditarry.splice(index, 1);
			},
			// 下载
			downloadFileFn(url, name) {
				downloadFile(url, name);
			},
			// 查看附件信息--点击预览图片 --pdf预览
			showPreview(extName, index, previweurl) {
				// 如果是图片类型
				if (isImageExtension(extName)) {
					previewImgs(filterImageData(this.filelist).showimages, index);
				} else {
					// 如果不是图片预览就是pdf预览
					previewPDF(previweurl);
				}
			},
			// 保存草稿
			sumitFn(type) {
				//必填校验
				if (
					this.pageInfo.title == '' ||
					this.pageInfo.publishTime == '' ||
					this.pageInfo.content == '' ||
					!['UNDO', 'DONE'].includes(this.pageInfo.businessStatus) ||
					(this.pageInfo.businessStatus == 'UNDO' && this.pageInfo.auditorIds == '') ||
					(this.pageInfo.publishScopeName == '指定传阅人' && this.pageInfo.readerIds == '')
				) {
					uni.showToast({
						title: '请填写必填项！',
						icon: 'none',
						duration: 1500
					});
					return;
				}
				if (type === '保存') {
					getSaveDrafat(this.pageInfo).then((res) => {
						this.showToastAndNavigate(res);
					});
				} else if (type === '提交') {
					handelauditSubmit(this.pageInfo).then((res) => {
						this.showToastAndNavigate(res);
					});
				}
			},
			//提交保存成功公共处理
			showToastAndNavigate(res) {
				uni.showToast({
					title: res.msg,
					icon: 'none',
					duration: 1500
				});
				setTimeout(() => {
					uni.navigateTo({
						url: '/documentManagement/commonNotice/list?tabtype=2'
					});
				}, 1000);
			},
			// 去选择审批人
			getPerson(title) {
				uni.navigateTo({
					url: '/documentManagement/selectPerson/circulate?titel=' + title+(title=='指定传阅人'?'&checkIds='+this.pageInfo.readerIds:'&checkIds='+this.pageInfo.auditorIds)
				});
			},
			// 选择传阅人和审核人
			circulateSumint() {
				const chosedata = JSON.parse(uni.getStorageSync('selectPsersonData') || 'null') || null;
				if (!chosedata) return;
				if (this.checkpersonTitel === '指定传阅人') {
					Object.assign(this.pageInfo, {
						readerNames: chosedata.names,
						readerIds: chosedata.ids,
						readerAccounts: chosedata.mobiles
					});
					return;
				}
				if (this.checkpersonTitel === '添加审批人') {
					// 合并新旧数据（自动去重）
					const mergeData = (key) => {
						const oldValues = (this.pageInfo[key]?.split(',') || []).filter(Boolean);
						const newValues = (chosedata[key]?.split(',') || []).filter(Boolean);
						return [...new Set([...oldValues, ...newValues])].join(',');
					};
					this.pageInfo.auditorIds = mergeData('ids');
					this.pageInfo.auditorNames = mergeData('names');
					this.pageInfo.auditorAccounts = mergeData('mobiles');
					this.auditarry = this.pageInfo.auditorNames.split(',');
				}
				uni.setStorageSync('selectPsersonData', null);
			},
			// 选择路径选择
			businessStatuschange(val) {
				this.pageInfo.businessStatusName = val;
				this.pageInfo.businessStatus = val == '送审' ? 'UNDO' : val == '发布信息' ? 'DONE' : '';
				this.checkpersonTitel = val == '送审' ? '添加审批人' : '';
				this.pageInfo.auditorIds = '';
				this.pageInfo.auditorNames = '';
				this.auditarry = [];
			},
			// 填写回执提交
			hzsumit() {
				if (!this.pageInfo.receiptMemo) {
					uni.showToast({
						title: '请填写回执内容！',
						icon: 'none',
						duration: 1500
					});
					return;
				}
				setReadStatus({
					noticeId: this.itId,
					receiptMemo: this.pageInfo.receiptMemo
				}).then((res) => {
					setTimeout(() => {
						uni.navigateTo({
							url: '/documentManagement/commonNotice/list?tabtype=1'
						});
					}, 1000);
				});
			},
			// tab切換
			checkTab(val) {
				this.tabcheck = val;
				// 切换到办理记录
				if (this.tabcheck == 2) {
					this.handlingRecord();
				}
				// 附件
				if (this.tabcheck == 3) {
					this.handlgetfilelist();
				}
			},
			// 获取附件列表
			handlgetfilelist() {
				getfilelist(this.businessId).then((res) => {
					this.filelist = res.data;
				});
			},
			//  办理记录
			handlingRecord() {
				gethandlingRecord(this.businessId).then((res) => {
					this.recordlist = res.data;
				});
			},
			// 点击保存
			handelSave() {
				// 我审批的---基本信息---保存
				if (this.tabtype == 'iapprove') {
					if (!this.pageInfo.auditMemo) {
						uni.showToast({
							title: '请先填写审批意见！',
							icon: 'none',
							duration: 1500
						});
						return;
					}
					iapproveSave({
						auditMemo: this.pageInfo.auditMemo,
						id: this.itId
					}).then((res) => {
						this.showToastAndNavigate();
					});
				}
				// 我创建的---已经审批--立即办理--基本信息---保存
				if (this.initbusinessStatus == 'AUDITED' && this.tabtype == 'icreat') {
					this.sumitFn('保存');
				}
			},
			// 点击提交
			handelSumit() {
				// 我审批的---基本信息---提交
				if (this.tabtype == 'iapprove') {
					if (!this.pageInfo.auditMemo) {
						uni.showToast({
							title: '请先填写审批意见！',
							icon: 'none',
							duration: 1500
						});
						return;
					}
					this.$refs.modal.open();
				}
				// 我创建的---已经审批--立即办理--基本信息---提交
				if (this.initbusinessStatus == 'AUDITED' && this.tabtype == 'icreat') {
					this.$refs.modal.open();
				}
			},
			//提交确认二次弹框（我审批的）
			confirm() {
				if (this.tabtype == 'iapprove') {
					iapproveSubmit({
						auditMemo: this.pageInfo.auditMemo,
						id: this.itId
					}).then((res) => {
						this.showToastAndNavigate();
					});
				}
				// 我创建的---已经审批--立即办理--基本信息---提交
				if (this.initbusinessStatus == 'AUDITED' && this.tabtype == 'icreat') {
					this.sumitFn('提交');
				}
			},
			//提交保存---成功公共处理
			showToastAndNavigate(res) {
				setTimeout(() => {
					uni.navigateTo({
						url: '/documentManagement/commonNotice/list?tabtype=3'
					});
				}, 1000);
			},
			// 获取基本信息数据
			getpageInfo() {
				// 我创建的  获取基本信息
				if (this.tabtype == 'icreat') {
					getauditInfo({
						id: this.businessId,
						businessType: this.businessType
					}).then((res) => {
						this.pageinfoPullic(res);
					});
				}
				// 我审批的的  获取基本信息
				if (this.tabtype == 'iapprove') {
					gettaskInfo({
						id: this.itId
					}).then((res) => {
						this.pageinfoPullic(res);
					});
				}
				// 通知公告 获取基本信息
				if (this.tabtype == 'notice') {
					getNoticeInfo({
						id: this.itId
					}).then((res) => {
						this.pageinfoPullic(res);
					});
				}
			},
			pageinfoPullic(res) {
				this.initbusinessStatus = res.data.businessStatus || res.data.auditInfo.businessStatus;
				if (this.initbusinessStatus == 'AUDITED' && this.tabtype == 'icreat') {
					this.pageInfo = this.autoMap(res.data, this.pageInfo);
					this.pageInfo.publishScopeName = res.data.publishScope == 'DESIGNEE' ? '指定传阅人' : '全部人员'
				} else {
					this.pageInfo = res.data;
				}
				if (this.tabtype !== 'notice') {
					this.busiAttachs = res.data.busiAttachs && res.data.busiAttachs.length > 0 ? res.data.busiAttachs : [];
				} else {
					this.busiAttachs = res.data.auditInfo.busiAttachs && res.data.auditInfo.busiAttachs.length > 0 ? res
						.data.auditInfo.busiAttachs : [];
					let filesdata = filterImageData(res.data.auditInfo.busiAttachs ? res.data.auditInfo.busiAttachs : []);
					this.showimglist = filesdata.images ? filesdata.images : [];
					this.infofilelist = filesdata.others ? filesdata.others : [];
				}
				if (this.tabtype == 'iapprove' || this.tabtype == 'notice') {
					this.auditItems = res.data.auditInfo.auditItems && res.data.auditInfo.auditItems.length > 0 ? res.data
						.auditInfo.auditItems : [];
				} else {
					this.auditItems = res.data.auditItems && res.data.auditItems.length > 0 ? res.data.auditItems : [];
				}
				if (res.data.noticeInfos && res.data.noticeInfos.length > 0) {
					this.tabs.push({
						lable: '阅读情况',
						value: 4
					});
					this.noticeInfos = res.data.noticeInfos;
				}
			},
			// 分页
			querylist(page, size) {
				console.log(page, size);
			},
			autoMap(source, target) {
				const filteredSource = Object.keys(target).reduce((acc, key) => {
					if (source.hasOwnProperty(key)) {
						// 处理null值为''或[]
						const value = source[key];
						acc[key] = value === null ?
							(typeof target[key] === 'string' ? '' : []) :
							value;
					}
					return acc;
				}, {});

				return {
					...target,
					...filteredSource
				};
			},
			backfn() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	@import '../../style/documentmanage.scss';

	.mainPge .frct .ctinfo_edit {
		::v-deep .uni-input-input {
			text-align: left !important;
			font-size: 15px;
			padding-bottom: 8px;
		}
	}
</style>